package com.googlecode.clearnlp.tokenization;

import com.googlecode.clearnlp.util.Span;

public class Token {
	private String s_text;
	private Span s_span;

	public Token(String text, int beginSpan) {
		this(text, beginSpan, beginSpan + text.length());
	}
	
	public Token(String text, int beginSpan, int endSpan) {
		this(text, new Span(beginSpan, endSpan));
	}
	
	public Token(String text) {
		this(text, new Span());
	}
	
	public Token(String text, Span span) {
		s_text = text;
		s_span = span;
		if (s_span.begin >= s_span.end)
			throw new RuntimeException("Invalid token span: " + s_span);
	}

	public String getText() {
		return s_text;
	}
	
	public void setText(String text) {
		s_text = text;
	}

	public Span getSpan() {
		return s_span;
	}

	public void setSpan(Span span) {
		s_span = span;
	}
	
	public String toString() {
		return s_text;
	}

}
